package com.tjec.project.mdmSynchronous.dao.impl;


import com.tjec.common.utils.StringUtils;
import com.tjec.project.mdmSynchronous.dao.AgencyNoDao;
import com.tjec.project.mdmSynchronous.dao.CostNoDao;
import com.tjec.project.mdmSynchronous.dao.ProjectContractDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @wjq
 * @date2019/8/29
 */
@Service
public class CostNoImpl implements CostNoDao {

    @Autowired
    private JdbcTemplate primaryJdbcTemplate;

    @Override
    public int updateCostNoStatus(String businessId,String status) {
    	if(StringUtils.isNotBlank(businessId)) {
    		String sql="update OA_yw_实施台账_造价报告管理 set EC业务状态='"+status+"' where [业务ID]='"+businessId+"'";
    		
    		if("作废".equals(status)) {
    			String sql2="update OA_yw_实施台账_造价报告管理 set 报告名称='(作废)' + 报告名称 where [业务ID]='"+businessId+"'";
    			primaryJdbcTemplate.update(sql2);
    		}else {
    			String sql3="update OA_yw_实施台账_造价报告管理 set 报告名称=substring(报告名称,5,LEN(报告名称)) where [业务ID]='"+businessId+"' and LEN(报告名称)>8 and substring(报告名称,1,4)='(作废)'";
    			primaryJdbcTemplate.update(sql3);
    		}
    		
    		return primaryJdbcTemplate.update(sql);
    	}else {
    		return 1;
    	}
    }

}
